package cn.yuhao.HellolServrlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class Login extends HttpServlet {
	
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		String username=request.getParameter("username");
		String password=request.getParameter("password");
		if(!"yuhao".equalsIgnoreCase(username)){
			HttpSession session=request.getSession();
			session.setAttribute("username", username);
			response.sendRedirect("/Day/index.jsp");
		}else{
			request.setAttribute("mag", "用户名或者密码错误");
			RequestDispatcher qr=request.getRequestDispatcher("/login.jsp");
			qr.forward(request, response);
		}
	}

}
